home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
005
/
miscstat.arc
/
CHSQTEST.BAS
< prev
next >
Wrap
BASIC Source File
|
1986-04-25
|
1KB
|
55 lines
1 'CHi-SQuare TEST
2 KEY OFF:SCREEN 0,0,0:WIDTH 80:COLOR 15,0,8:CLS
10 PRINT "CHI-SQUARE TEST"
20 PRINT
30 DIM V1(25),V2(5),A(5)
40 PRINT "NUMBER OF ROWS";
50 INPUT R:IF R<1 OR R>5 THEN 50
60 PRINT "NUMBER OF COLUMNS";
70 INPUT C:IF C<1 OR C>5 THEN 70
80 PRINT "CONTINGENCY TABLE:"
90 FOR I = 1 TO R
100 PRINT "ROW";I
110 FOR J = 1 TO C
120 PRINT "ELEMENT";J;
130 INPUT V1((I - 1) * C + J)
140 NEXT J
150 NEXT I
160 PRINT
170 L = 0
180 M = 1
190 FOR I = 1 TO R
200 FOR J = 1 TO C
210 A(I) = A(I) + V1(M)
220 M = M + 1
230 NEXT J
240 L = L + A(I)
250 NEXT I
260 N = R * C
270 FOR I = 1 TO C
280 FOR J = I TO N STEP C
290 V2(I) = V2(I) + V1(J)
300 NEXT J
310 NEXT I
320 Z = 0
330 PRINT ,"OBSER","EXPECT","CHI²"
340 FOR I = 1 TO C
350 PRINT " COLUMN ";I;
360 FOR J = 1 TO R
370 P = A(J) * V2(I) / L
380 X = I + (J - 1) * C
390 Y = (V1(X) - P) ^ 2 / P
400 Z = Z + Y
410 PRINT ,V1(X),INT(P*10000+.5)/10000,INT(Y*10000+.5)/10000
420 NEXT J
430 NEXT I
440 PRINT
450 PRINT "CHI-SQUARE IS";Z
460 PRINT "DEGREES OF FREEDOM IS";(C - 1) * (R - 1)
470 PRINT:LOCATE 24,1:PRINT"PRESS <SPACE> TO RUN AGAIN";
480 LOCATE 25,1:PRINT"PRESS <ESC> TO EXIT";
490 K$=INKEY$:IF K$="" THEN 490
500 IF K$=" " THEN RUN
510 IF K$<>CHR$(27) THEN 490
10000 RUN"MENU